home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Examples / Draw / Include / Utils.h < prev   
Encoding:
Text File  |  1995-11-08  |  4.8 KB  |  173 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                Utils.h
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Author:                Henri Lamiraux
  7. //
  8. //    Copyright:    © 1993, 1995 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef UTILS_H
  13. #define UTILS_H
  14.  
  15. #ifndef FWGC_H
  16. #include "FWGC.h"
  17. #endif
  18.  
  19. // ----- OS Layer -----
  20.  
  21. #ifndef FWPOINT_H
  22. #include "FWPoint.h"
  23. #endif
  24.  
  25. #ifndef FWINK_H
  26. #include "FWInk.h"
  27. #endif
  28.  
  29. #ifndef FWSTYLE_H
  30. #include "FWStyle.h"
  31. #endif
  32.  
  33. #ifndef FWGRDEF_H
  34. #include "FWGrDef.h"
  35. #endif
  36.  
  37. #ifndef FWSUSINK_H
  38. #include "FWSUSink.h"
  39. #endif
  40.  
  41. // ----- FOundation Layer -----
  42.  
  43. #ifndef FWSTDDEF_H
  44. #include "FWStdDef.h"
  45. #endif
  46.  
  47. //========================================================================================
  48. //    Forward Declarations
  49. //========================================================================================
  50.  
  51. #if FW_LIB_EXPORT_PRAGMAS
  52. #pragma import on
  53. #endif
  54. class FW_CLASS_ATTR FW_CFacetContext;
  55. class FW_CLASS_ATTR FW_CRect;
  56. class FW_CLASS_ATTR FW_CStorageUnitSink;
  57. class FW_CLASS_ATTR FW_CCloneInfo;
  58. #if FW_LIB_EXPORT_PRAGMAS
  59. #pragma import off
  60. #endif
  61.  
  62. class FW_CLASS_ATTR CDrawPart;
  63.  
  64. //========================================================================================
  65. //    Class CGrid
  66. //========================================================================================
  67. // index, row and column are 0 based
  68. //
  69. //    Index Example         0 | 1 | 2
  70. //                        ---------
  71. //                        3 | 4 | 5
  72. //
  73.  
  74. class FW_CLASS_ATTR CGrid
  75. {
  76. public:
  77.     CGrid(unsigned short rows, unsigned short columns, 
  78.          const FW_CPoint& position, 
  79.          const FW_CPoint& cellInterior, 
  80.          FW_CFixed penSize);
  81.  
  82.     FW_Boolean        FindCell(const FW_CPoint& where, unsigned long& index) const;
  83.     FW_Boolean        FindCell(const FW_CPoint& where, unsigned short& row, unsigned short& column) const;
  84.     
  85.     void            GetCellInterior(unsigned short row, unsigned short column, FW_CRect& rect) const;
  86.     void            GetCellInterior(unsigned long index, FW_CRect& rect) const;
  87.  
  88.     void            GetCellExterior(unsigned short row, unsigned short column, FW_CRect& rect) const;
  89.     void            GetCellExterior(unsigned long index, FW_CRect& rect) const;
  90.  
  91.     void            GetExteriorGridRect(FW_CRect& rect) const;
  92.     void            GetInteriorGridRect(FW_CRect& rect) const;
  93.     
  94.     unsigned long    GetIndex(unsigned short row, unsigned short column) const
  95.                         {return row * fColumns + column;}
  96.                     
  97.     void            GetRowColumn(unsigned long index, unsigned short& row, unsigned short& column) const;
  98.  
  99.     void            DrawGridBorders(FW_CFacetContext& fc, const FW_PInk& ink = FW_kNormalInk, const FW_PStyle& style = FW_kNormalStyle);
  100.     
  101. private:
  102.     unsigned short    fRows;
  103.     unsigned short    fColumns;
  104.     FW_CPoint        fPosition;
  105.     FW_CPoint        fCellSize;
  106.     FW_CFixed        fHalfPenSize;
  107. };
  108.  
  109. //========================================================================================
  110. //    Class CWidget
  111. //========================================================================================
  112.  
  113. class FW_CLASS_ATTR CWidget
  114. {
  115. public:
  116.     CWidget(FW_ResourceId resId);
  117.     ~CWidget();
  118.     
  119.     void    Render(FW_CFacetContext& fc, const FW_CRect& rect); 
  120.  
  121. private:
  122.     FW_ResourceId         fResId;
  123.  
  124. };
  125.  
  126. //========================================================================================
  127. //    class CDrawReadableStream
  128. //========================================================================================
  129. //    This is a hack until I can pass data through the archiver
  130.  
  131. class FW_CLASS_ATTR CDrawReadableStream : public FW_CReadableStream
  132. {
  133. public:
  134.     CDrawReadableStream(Environment* ev, CDrawPart* drawPart, FW_CStorageUnitSink* sink, FW_CCloneInfo* cloneInfo);
  135.     virtual ~CDrawReadableStream();
  136.     
  137.     Environment*            GetEnvironment() const
  138.                                 {return fEnvironment;}
  139.     CDrawPart*                GetDrawPart() const
  140.                                 {return fDrawPart;}
  141.     FW_CCloneInfo*            GetCloneInfo() const
  142.                                 {return fCloneInfo;}
  143.     ODStorageUnitView*        GetStorageUnitView() const
  144.                                 {return ((FW_CStorageUnitSink*)GetSink())->GetStorageUnitView();}
  145. private:
  146.     Environment*            fEnvironment;
  147.     CDrawPart*                fDrawPart;
  148.     FW_CCloneInfo*            fCloneInfo;
  149. };
  150.  
  151. //========================================================================================
  152. //    class CDrawReadableStream
  153. //========================================================================================
  154. //    This is a hack until I can pass data through the archiver
  155.  
  156. class FW_CLASS_ATTR CDrawWritableStream : public FW_CWritableStream
  157. {
  158. public:
  159.     CDrawWritableStream(Environment* ev, FW_CStorageUnitSink* sink, FW_CCloneInfo* cloneInfo);
  160.     virtual ~CDrawWritableStream();
  161.     
  162.     Environment*            GetEnvironment() const
  163.                                 {return fEnvironment;}
  164.     FW_CCloneInfo*            GetCloneInfo() const
  165.                                 {return fCloneInfo;}
  166.     ODStorageUnitView*        GetStorageUnitView() const
  167.                                 {return ((FW_CStorageUnitSink*)GetSink())->GetStorageUnitView();}
  168. private:
  169.     Environment*            fEnvironment;
  170.     FW_CCloneInfo*            fCloneInfo;
  171. };
  172.  
  173. #endif